<template>
	<view class="doctor-recommend-page">
		<!-- 标题区域 -->
		<view class="title-wrap">
			<text class="title">推荐医生</text>
		</view>

		<!-- 医生列表 -->
		<view class="doctor-list">
			<u-card v-for="(item, index) in doctorList" :key="index" :border="false" margin="0 0 20rpx 0"
				:class="['doctor-card', index === 0 ? 'first-card' : '']"
				box-shadow="0 2rpx 12rpx 0 rgba(0, 0, 0, 0.06)">
				<view slot="body" class="doctor-card-body">
					<!-- 左侧医生信息 -->
					<view class="doctor-info-left">
						<u-avatar :src="item.avatar" size="120" :class="['doctor-avatar']"></u-avatar>
					</view>

					<!-- 右侧医生详情 -->
					<view class="doctor-info-right">
						<view class="doctor-basic-info">
							<text class="doctor-name">{{ item.doctorName }}</text>
							<text
								class="doctor-position">{{ item.doctorLevelId == 0 ? "主治医师" : item.doctorLevelId == 1 ? "副主任医师" : "主任医师" }}</text>
							<text class="doctor-department">{{ item.departmentName }}</text>
						</view>

						<!-- 推荐度（星星）替换医院信息 -->
						<view class="recommendation">
							<text class="recommend-label">推荐度：</text>
							<view class="stars">
								<text class="star" v-for="(star, sIndex) in 5" :key="sIndex"
									:class="sIndex < item.doctorRating ? 'active' : ''">★</text>
							</view>
							<!-- <text class="recommend-score">{{ item.recommendLevel }}.0
								({{ item.recommendCount }}人推荐)</text> -->
						</view>

						<view class="doctor-expertise">
							<text class="expertise-label">擅长：</text>
							<text class="expertise-content">{{ item.doctorDescription }}</text>
						</view>
					</view>
				</view>

				<view slot="foot" class="doctor-card-foot">
					<u-button :custom-style="consultBtnStyle" @click="ConsultationDoc(item)" :hair-line="false">
						预约咨询
					</u-button>
				</view>
			</u-card>
		</view>
	</view>
</template>

<script>
	import {
		commendDoctor
	} from '@/api/index.js';
	export default {
		data() {
			return {
				// 咨询按钮样式
				consultBtnStyle: {
					width: '200rpx',
					height: '60rpx',
					lineHeight: '60rpx',
					background: 'linear-gradient(90deg, #4E89F0 0%, #6BA1F7 100%)',
					color: '#fff',
					borderRadius: '30rpx',
					fontSize: '26rpx'
				},
				// 医生列表数据（新增推荐度相关字段）
				doctorList: [{
					doctorId: '',
					avatar: "",
					doctorName: "",
					doctorLevelId: '', // 副主任医师
					departmentName: "",
					doctorDescription: "",
					doctorRating: '' // 推荐星级（1-5）
					/* recommendCount: 128 // 推荐人数 */
				}]
			};
		},
		mounted() {
			this.getCommendTable()
		},
		methods: {
			getCommendTable() {
				commendDoctor().then(res => {
					//console.log(res)
					if (res.code === 1) {
						this.doctorList = res.data
					}
				})
			},
			ConsultationDoc(item) {
				//console.log("咨询医生:", item.doctorId);
				uni.navigateTo({
					url: `/pages/appointment/appointmentList??doctorId=${item.doctorId}`
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	.doctor-recommend-page {
		padding: 30rpx;
		background-color: #f7f7f7;
		min-height: 100vh;
		box-sizing: border-box;
	}

	.title-wrap {
		margin-bottom: 30rpx;

		.title {
			font-size: 36rpx;
			font-weight: bold;
			color: #333;
		}
	}

	.doctor-card {
		border-radius: 16rpx;
		overflow: hidden;

		/* 卡片主体部分 */
		.doctor-card-body {
			display: flex;
			padding: 30rpx 30rpx 20rpx;
		}

		/* 左侧医生头像区域 */
		.doctor-info-left {
			margin-right: 24rpx;
			flex-shrink: 0;

			.doctor-avatar {
				border: 4rpx solid #f0f5ff;
			}
		}

		/* 右侧医生信息区域 */
		.doctor-info-right {
			flex: 1;
			display: flex;
			flex-direction: column;

			.doctor-basic-info {
				display: flex;
				align-items: center;
				margin-bottom: 12rpx;
				flex-wrap: wrap;

				.doctor-name {
					font-size: 32rpx;
					font-weight: bold;
					color: #333;
					margin-right: 16rpx;
				}

				.doctor-position {
					font-size: 24rpx;
					color: #666;
					margin-right: 16rpx;
				}

				.doctor-department {
					font-size: 24rpx;
					color: #666;
				}
			}

			/* 推荐度样式 */
			.recommendation {
				display: flex;
				align-items: center;
				margin-bottom: 16rpx;
				flex-wrap: wrap;

				.recommend-label {
					font-size: 26rpx;
					color: #999;
					margin-right: 10rpx;
					flex-shrink: 0;
				}

				.stars {
					margin-right: 10rpx;
					display: flex;

					.star {
						font-size: 28rpx;
						color: #ddd;
						margin-right: 2rpx;

						&.active {
							color: #FFD700; // 金色星星
							text-shadow: 0 0 2rpx rgba(255, 215, 0, 0.5);
						}
					}
				}

				.recommend-score {
					font-size: 24rpx;
					color: #666;
				}
			}

			.doctor-expertise {
				display: flex;
				margin-bottom: 20rpx;
				flex-wrap: wrap;

				.expertise-label {
					font-size: 26rpx;
					color: #999;
					flex-shrink: 0;
					margin-right: 10rpx;
				}

				.expertise-content {
					font-size: 26rpx;
					color: #666;
					line-height: 1.4;
					flex: 1;
				}
			}
		}

		/* 卡片底部 */
		.doctor-card-foot {
			display: flex;
			justify-content: flex-end;
			padding: 0 30rpx 30rpx;
		}
	}
</style>